<?php

/**
 * paypal帐户
 */
class Application_Model_PaypalRisk extends Application_Model_DomainObject {
    
    protected $_id;
    protected $_payer_email;             //
    protected $_txn_id;                  //
    protected $_amount;                  //
    protected $_uuch_user_id;            //
    protected $_reason;                  //
    protected $_created_at;              // 
	protected $_remark;
	protected $_domain_type;
	protected $_domain_id;
	protected $_pass;  	
	
	 public static function getFilter($quick, $dateinbegin,$dateinend, $pagesize, $pageindex)
    {
        $where = array();
        $and = "";
        $where["pass ="]=0;
        if($quick != ""){
            $where[" and ( payer_email like "] = "%".$quick."%";
			$where[" or txn_id like "] = "%".$quick."%";           
            $where[" ) and "] = 1;
        }
        if ($dateinbegin != "") {
            $and = " and ";
            $where[$and . " created_at >= "] = $dateinbegin;
        }
        if ($dateinend != "") {
            $and = " and ";
            $where[$and . " created_at <= "] = $dateinend;
            
        }
        return self::getDao()->queryPage($where, "created_at desc", $pagesize, $pageindex);
    }

     public static function getFilters($quick, $dateinbegin,$dateinend, $pagesize, $pageindex)
    {
        $where = array();
        $and = "";
        $where["pass !="]=0;
        if($quick != ""){
            $where[" and ( payer_email like "] = "%".$quick."%";
            $where[" or txn_id like "] = "%".$quick."%";           
            $where[" ) and "] = 1;
            $and = " and ";
        }
        if ($dateinbegin != "") {
            $where[$and . " created_at >= "] = $dateinbegin;
            $and = " and ";
        }
        if ($dateinend != "") {
            $where[$and . " created_at <= "] = $dateinend;
            $and = " and ";
        }
        return self::getDao()->queryPage($where, "created_at desc", $pagesize, $pageindex);
    }
    public static function  getPaypalOrder($object){
        $order=array();   
        if (count($object['list']) > 0)  {
            foreach($object['list'] as $papay){
                $row[]=$papay->userId;
            }
            $rows=implode(',',$row);
            $where["  pass = "] = 0;
            $where[' and uuch_user_id  in '] ="($rows)";
            $rowObject=self::getDao()->queryAll($where);        
            foreach($rowObject as $orderPay){
                $order[]=$orderPay->uuch_user_id;
            }
        }
        return $order;
    }

    public static function  getWaybill($id){
        $where[" pass = "] = 0;
        $where[' and uuch_user_id = '] ="$id";
        return self::getDao()->queryAll($where);   
    }

    public static function  getVisiting($id){
        $where[" pass = "] = 0;
        $where[' and uuch_user_id = '] ="$id";
        return self::getDao()->queryAll($where);     
    }

    public static function  getAgentPay($id){
        $where[" pass = "] = 0;
        $where[' and uuch_user_id = '] ="$id";
        return self::getDao()->queryAll($where);  
    }
}